﻿using System;
using System.Text;
using TinyIpc.Messaging;

namespace Client
{
  class Program
  {
    static  void Main(string[] args)
    {
      var messagebus1 = new TinyMessageBus("ExampleChannel");

      messagebus1.MessageReceived += Messagebus1_MessageReceived;
      while (true)
      {
        var message = Console.ReadLine();
        if (!string.IsNullOrEmpty(message))
        {
          messagebus1.PublishAsync(Encoding.UTF8.GetBytes(message));
        }
      
      }

      Console.ReadKey();
    }

    private static void Messagebus1_MessageReceived(object sender, TinyMessageReceivedEventArgs e)
    {
      Console.Write(Encoding.UTF8.GetString( e.Message));
    }
  }
}
